package kr.co.doriclassic.forloop;

public class Sum3 {
	int sCount;
	private String inpNum ;
	private String[] sNum;
	private int sum;	
	
	public Sum3(String inpNum) {
		this.inpNum = inpNum;
	}
	
	public int sumCount(){
		sNum = inpNum.split(" ");
		//문자열 비교는 equals로 한다.
		for(int i=0;i<(sNum.length);i++){
			if(!sNum[i].equals("0")){
				System.out.print(sNum[i]+ " ");
				sum+=Integer.parseInt(sNum[i]);
			}	
			else{
				break;
			}
		}
		return sum;
	}

	@Override
	public String toString() {
		return "의 합은" + sumCount() + "입니다.";
	}
	
}
